<!DOCTYPE html>
<html lang="en">
<title>企业储值卡管理</title>
<#import "/layout/layout.html" as body/>

<@body.page>
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <h2>企业储值卡管理</h2>
        <ol class="breadcrumb">
            <li><a href="#">企业储值账户列表</a></li>
            <#if companyStaff??>
                <li class="active"><strong>编辑员工</strong></li>
                <#else>
                    <li class="active"><strong>新增员工</strong></li>
            </#if>
        </ol>
    </div>
</div>
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title overflow">
                    <#if companyStaff??>
                        <h5 class="pull-left">编辑员工</h5>
                        <#else>
                            <h5 class="pull-left">新增员工</h5>
                    </#if>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal" id="addForm">
                        <input type="hidden" id="id" name="id" value="${(companyStaff.id)!}">
                        <input type="hidden" id="companyId" name="companyId" value="${company.id}">
                        <input type="hidden" id="status" name="status" value="${(companyStaff.status)!}">
                        <input type="hidden" id="version" name="version" value="${(companyStaff.version)!}">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">员工姓名</label>
                            <div class="col-sm-10">
                                <input type="text" id="name" name="name" value="${(companyStaff.name)!}" class="form-control" placeholder="请输入员工姓名">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">员工手机号</label>
                            <div class="col-sm-10">
                                <input type="text" id="mobile" name="mobile" value="${(companyStaff.mobile)!}" class="form-control" placeholder="请输入员工手机号码">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group"><label class="col-sm-2 control-label">限制员工每月限额</label>
                            <div class="col-sm-10" id="changeQuota">
                                <div class="checkbox-inline i-checks"><label for="changeYes"> <input type="radio" id="changeYes" value="0" name="isMonthlyLimit" <#if companyStaff?? && companyStaff.isMonthlyLimit=0>checked <#elseif !companyStaff?? && company?? && company.isMonthlyLimit=0>checked </#if> > <i></i> 限制 </label></div>
                                <div class="checkbox-inline i-checks"><label for="changeNo"> <input type="radio" id="changeNo" value="1" name="isMonthlyLimit" <#if companyStaff?? && companyStaff.isMonthlyLimit=1>checked <#elseif !companyStaff?? && company?? && company.isMonthlyLimit=1>checked </#if> > <i></i> 不限 </label></div>
                            </div>
                        </div>
                        <!--<div class="hr-line-dashed"></div>-->
                        <!--<div class="form-group quota-limit">-->
                            <!--<label class="col-sm-2 control-label">设置每月限额</label>-->
                            <!--<div class="col-sm-10">-->
                                <!--<input type="text" id="monthlyLimit" name="monthlyLimit" value="${(companyStaff.monthlyLimit)!}" class="form-control" placeholder="设置该员工的每月初始限额">-->
                            <!--</div>-->
                        <!--</div>-->
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">员工每月限额</label>
                            <div class="col-sm-10">
                                <#if companyStaff??>
                                    <input type="text" id="amount" name="amount" value="${(companyStaff.amount)!}" class="form-control" placeholder="请输入新增该员工每月限额">
                                    <#else>
                                        <input type="text" id="amount" name="amount" value="${(company.monthlyLimit)!}" class="form-control" placeholder="请输入新增该员工每月限额">
                                </#if>


                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group"><label class="col-sm-2 control-label">限制可买类型</label>
                            <div class="col-sm-10" id="setLimit">
                                <div class="checkbox-inline i-checks"><label for="setLimitYes"> <input type="radio" id="setLimitYes" value="0" name="isBuyTypeLimit"
                                    <#if companyStaff??>
                                        <#if companyStaff?? && companyStaff.isBuyTypeLimit=0>checked</#if>
                                        <#else>
                                            <#if company?? && company.isBuyTypeLimit=0>checked</#if>
                                    </#if>
                                    > <i></i> 是 </label></div>
                                <div class="checkbox-inline i-checks"><label for="setLimitNo"> <input type="radio" id="setLimitNo" value="1" name="isBuyTypeLimit"
                                    <#if companyStaff??>
                                        <#if companyStaff?? && companyStaff.isBuyTypeLimit=1>checked</#if>
                                        <#else>
                                            <#if company?? && company.isBuyTypeLimit=1>checked</#if>
                                    </#if>
                                    > <i></i> 否 </label></div>

                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group"><label class="col-sm-2 control-label">选择可买类型</label>
                            <div class="col-sm-10" id="DefaultType">
                                <div class="checkbox-inline i-checks"><label for="team"> <input type="checkbox" id="team" value="1" name="limitTeamCourse"
                                    <#if companyStaff??>
                                        <#if companyStaff?? && companyStaff.limitTeamCourse?? && companyStaff.limitTeamCourse=1>checked </#if>
                                        <#else>
                                            <#if company?? && company.limitTeamCourse?? && company.limitTeamCourse=1>checked</#if>
                                    </#if>

                                    > <i></i> 团课 </label></div>
                                <div class="checkbox-inline i-checks"><label for="personal"> <input type="checkbox" id="personal" value="1" name="limitSecretCourse"
                                    <#if companyStaff??>
                                        <#if companyStaff?? && companyStaff.limitSecretCourse?? && companyStaff.limitSecretCourse=1>checked</#if>
                                        <#else>
                                            <#if company?? && company.limitSecretCourse?? && company.limitSecretCourse=1>checked</#if>

                                    </#if>
                                    > <i></i> 私教 </label></div>
                                <div class="checkbox-inline i-checks"><label for="camp"> <input type="checkbox" id="camp" value="1" name="limitCampCourse"
                                    <#if companyStaff??>
                                        <#if companyStaff?? && companyStaff.limitCampCourse?? && companyStaff.limitCampCourse=1>checked</#if>
                                        <#else>
                                            <#if company?? && company.limitCampCourse?? && company.limitCampCourse=1>checked</#if>

                                    </#if>
                                    > <i></i> 训练营 </label></div>
                                <div class="checkbox-inline i-checks"><label for="self"> <input type="checkbox" id="self" value="1" name="limitSelfCourse"
                                    <#if companyStaff??>
                                        <#if companyStaff?? && companyStaff.limitSelfCourse?? && companyStaff.limitSelfCourse=1>checked</#if>
                                        <#else>
                                            <#if company?? && company.limitSelfCourse?? && company.limitSelfCourse=1>checked</#if>
                                    </#if>
                                    > <i></i> 自助 </label></div>
                                <div class="checkbox-inline i-checks"><label for="vip"> <input type="checkbox" id="vip" value="1" name="limitVip"
                                    <#if companyStaff??>
                                        <#if companyStaff?? &&companyStaff.limitVip??  && companyStaff.limitVip=1>checked</#if>
                                        <#else>
                                            <#if company?? &&company.limitVip??  && company.limitVip=1>checked</#if>
                                    </#if>
                                    > <i></i> 会员 </label></div>
                                <!--<div class="checkbox-inline i-checks"><label for="card"> <input type="checkbox" id="card" value="1" name="limitValuedCard"-->
                                    <!--<#if companyStaff??>-->
                                        <!--<#if companyStaff?? && companyStaff.limitValuedCard?? && companyStaff.limitValuedCard=1>checked</#if>-->
                                        <!--<#else>-->
                                            <!--<#if company?? && company.limitValuedCard?? && company.limitValuedCard=1>checked</#if>-->
                                    <!--</#if>-->
                                    <!--&gt; <i></i> 储值卡 </label></div>-->
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">备注</label>
                            <div class="col-sm-10">
                                <input type="text" id="remark" name="remark" value="${(companyStaff.remark)!}" class="form-control" placeholder="非必填，可输入相关备注信息">
                            </div>
                        </div>
                    </form>
                </div>
                <div class="ibox-content overflow">
                    <div class="col-sm-12">
                                <a id="go_back_list" href="${baseUrl}system/company/empl_list?companyId=${company.id}" class="btn btn-default pull-left">
                                    <#if companyStaff??>
                                        返回
                                        <#else>
                                        取消添加
                                    </#if>
                                </a>

                        <a href="#" onclick="save_company_staff()" class="btn btn-primary pull-right">
                            <#if companyStaff??>
                                更新
                                <#else>
                                保存
                            </#if>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(document).ready(function() {
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });
        if($('#setLimitNo').parent().hasClass('checked')) {
            $('#DefaultType .icheckbox_square-green').addClass('disabled');
        }
        if($('#changeNo').parent().hasClass('checked')) {
            $('#amount').attr('disabled', 'true');
        }
    });
    $('#changeQuota input').on('ifChecked', function () {
        if ($(this).val() === '0') {
            $('#amount').removeAttr("disabled");
        } else {
            $('#amount').attr('disabled', 'true');
        }
    });
    $('#setLimit input').on('ifChecked', function () {
        if ($(this).val() === '0') {
            $('#DefaultType input').removeAttr("disabled");
            $('#DefaultType .icheckbox_square-green').removeClass('disabled')
        } else {
            $('#DefaultType input').attr('disabled', 'true');
            $('#DefaultType .icheckbox_square-green').addClass('disabled')
        }
    });

    /**
     * 企业员工保存
     *
     */
    function save_company_staff() {
        var param = $("#addForm").serialize();
        $.post("${baseUrl}system/company/saveCompanyStaff", param, function (result) {
            result = JSON.parse(result);
            if (result && result.go == "list"){
                swal("更新成功!", "页面即将重新加载,请稍后...", "success");
                window.setTimeout(function () {
                    window.location = '${baseUrl}system/company/empl_list?companyId=' + $("#companyId").val()
                }, 1000);
            } else if(result && result.success){
                swal("保存成功!", "页面即将重新加载,请稍后...", "success");
                window.setTimeout(function () {
                    window.location = '${baseUrl}system/company/empl_list?companyId=' + $("#companyId").val()
                }, 1000);
            } else {
                swal("保存失败!", result.msg, "error");
            }
        });
    }
</script>
</@body.page>
</html>